#  This file is part of FlickFleck.
#
#    FlickFleck is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    FlickFleck is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with FlickFleck.  If not, see <http://www.gnu.org/licenses/>.
#
import config
import i18n
import Tkinter
import Pmw
import wins
import sys

# simple window to display about and copyright information
class About:
    def __init__(self, parent):
        self.parent = parent

        infotext = config.TITLE + ' version: ' + config.VERSION + \
                   '\n\nA tool to copy, rotate and rename' + \
                   '\ndigital camera jpeg files.' + \
                   '\n\nPython version: ' + sys.version + \
                   '\nPmw version: ' + Pmw.version() + \
                   '\nRunning on: ' + sys.platform + \
		   '\n\nhttp://flickfleck.googlecode.com/'
        
        
        self.w_dialog = Pmw.Dialog( parent,
                                    buttons = ('OK',),
                                    defaultbutton = 'OK',
                                    title = i18n.name['menu_about'] + ' ' +
                                    config.TITLE, command = self.button )
        self.w_dialog.withdraw()

        self.w_notebook = Pmw.NoteBook( self.w_dialog.interior() )
        self.w_notebook.pack( fill = 'both', expand = 1, padx = 2, pady = 2 )

        self.addtab( 'Info', infotext )
        self.addtab( 'Copyright', wins.COPYRIGHT )
        self.addtab( 'Disclaimer', wins.DISCLAIMER )
        self.addtab( 'Tools', wins.TOOLS )        
        self.addtab( 'Pmw', wins.PMW )
        gpltab = self.w_notebook.add( 'GPLv3' )
        gpl = Pmw.ScrolledText( gpltab, hscrollmode = 'none' )
        gpl.importfile( 'GPL.txt' )
        gpl.component('text').config( state = Tkinter.DISABLED )
        gpl.pack( padx = 5, pady = 5, expand = 1 )
        
        self.w_notebook.tab('Info').focus_set()        
        self.w_notebook.setnaturalsize()


    def addtab( self, name, text ):
        tab = self.w_notebook.add( name )
        label = Tkinter.Label( tab,
                               text = text,
                               pady = 10 )
        label.pack( expand = 1, fill = 'both', padx = 2, pady = 2 )
        
            
    def show(self):
        self.w_dialog.activate(geometry = 'centerscreenalways')

    def button(self, result):
        self.w_dialog.deactivate( result )
        
